import 'package:flutter/material.dart';
import 'package:sow_app_core/sow_app_core.dart';

import 'tag_novel_page.dart';

class ClassifyListTile extends StatelessWidget {
  const ClassifyListTile(
      {Key? key, required this.parent, required this.children})
      : super(key: key);
  final Classify parent;
  final List<Classify> children;
  @override
  Widget build(BuildContext context) {
    return SizedBox(
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Padding(
            padding: const EdgeInsets.all(8.0),
            child: Text(
              parent.parentName,
              style: Theme.of(context).textTheme.headline4,
            ),
          ),
          GridView.builder(
            physics: const NeverScrollableScrollPhysics(),
            shrinkWrap: true,
            gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
              crossAxisCount: 2,
              childAspectRatio: 3.0,
            ),
            itemCount: children.length,
            itemBuilder: (context, index) => Padding(
              padding: const EdgeInsets.all(8.0),
              child: OutlinedButton(
                onPressed: () {
                  Navigator.pushNamed(context, TagNovelListPage.routeName,
                      arguments: children[index]);
                },
                child: Align(
                  alignment: Alignment.centerLeft,
                  child: Text(
                    children[index].classifyName,
                    style: Theme.of(context).textTheme.headline6,
                  ),
                ),
              ),
            ),
          ),
        ],
      ),
    );
  }
}
